<!DOCTYPE html>
<html xmlns:padding="http://www.w3.org/1999/xhtml" xmlns:font-size="http://www.w3.org/1999/xhtml"
      xmlns:background="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/css/dataTables.bootstrap.min.css">
    <link rel="stylesheet" type="text/css" media="screen" href="../../global/layui/css/layui.css">

</head>
<body>


<div>
    <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
        <header style="height: 100%">
            <div align="left">
                <table style="width: 100%">
                    <tr>
                        <td align="left">
                            <button class="layui-btn layui-btn-sm" onclick=""
                                    permission="trading:add">
                                <i class="layui-icon">&#xe66c;</i> 订单信息
                            </button>
                        </td>
                    </tr>
                </table>
            </div>
        </header>

        <div>
            <div class="widget-body no-padding">
                <table id="dt-table" class="table table-striped table-bordered table-hover" style="width:100%">
                    <thead>
                    <tr>
                    </tr>
                    <tr>
                        <th style="width: 5%">订单号</th>
                        <th style="width: 5%">商品名</th>
                        <th style="width: 8%">商品规格</th>
                        <th style="width: 8%">购买数量</th>
                        <th style="width: 8%">下单时间</th>
                        <th style="width: 10%">订单总金额</th>
                        <th style="width: 10%">预计到账金额</th>
                        <th style="width: 8%">配送方式</th>
                        <th style="width: 8%">订单类别</th>
                    </tr>
                    </thead>
                    <tbody>
                    </tbody>
                </table>
            </div>
        </div>
    </div>
<br><br><br><br><br><br><br><br>
    <div>
        <i class="layui-icon">&#xe66c;</i> 买家信息
        <div class="widget-body no-padding">
            <span id="test1">买家昵称</span>&nbsp&nbsp&nbsp&nbsp
            <span  id="test2">手机号</span>&nbsp&nbsp&nbsp&nbsp
            <span id="test3">收货地址:</span><br><br>
            <span id="test4">买家留言:</span>
        </div>
    </div>


    <div class="form-actions">
        <div class="row" align="center">
            <div class="col-md-12">
                <button class="btn btn-primary" onclick="location.href='orderList.html'">订单已发出</button>
                <button class="btn btn-primary" onclick="location.href='orderList.html'">取消订单</button>
            </div>
        </div>
    </div>

</div>
</body>
</html>

<script type="text/javascript" src="../../global/js/libs/jquery-2.1.1.min.js"></script>
<script type="text/javascript" src="../../global/js/jq.js"></script>
<script type="text/javascript" src="../../global/js/plugin/datatables/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="../../global/js/plugin/datatables/dataTables.bootstrap.min.js"></script>
<script type="text/javascript" src="../../global/layui/layui.js"></script>
<script type="text/javascript" src="../../global/js/my/permission.js"></script>
<script type="text/javascript">
    var pers = checkPermission();

    var example;

/*    layui.use('upload', function () {
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#test1' //绑定元素
            , url: '/upload/' //上传接口
            , done: function (res) {
                //上传完毕回调
            }
            , error: function () {
                //请求异常回调
            }
        });
    });*/

    function init() {
        example =
            $('#dt-table').DataTable({
                "searching": false,
                "processing": false,
                "serverSide": true,
                "language": {
                    "url": "/global/js/plugin/datatables/Chinese.lang"
                },
                "ajax": {
                "url": "/goodsOrderDetails/selectOrderBytradeNo",
                    "type": "get",
                    "data": function (d) {
                        d.goodsName = $('#name').val();
                    },
                    "error": function (xhr, textStatus, errorThrown) {
                        var msg = xhr.responseText;
                        console.log(msg);
                        var response = JSON.parse(msg);
                        var code = response.code;
                        var message = response.message;
                        if (code == 400) {
                            layer.msg(message);
                        } else if (code == 401) {
                            localStorage.removeItem("token");
                            layer.msg("token过期,请先登录", {shift: -1, time: 1000}, function () {
                                location.href = '/login.html';
                            });
                        } else if (code == 403) {
                            console.log("未授权:" + message);
                            layer.msg('未授权');
                        } else if (code == 500) {
                            layer.msg('系统错误:' + message);
                        }
                    },
               /*     "success":function (result) {
                       var data =  result.data
                        console.log(data)
                    }*/
                },
                "dom": "<'dt-toolbar'r>t<'dt-toolbar-footer'<'col-sm-10 col-xs-12 hidden-xs'i><'col-xs-12 col-sm-10' p v>>",
                "columns": [
                    {"data": "tradeNo", "defaultContent": ""},
                    {"data": "goodsName", "defaultContent": ""},
                    {"data": "goodsSpec", "defaultContent": ""},
                    {"data": "goodsAmount", "defaultContent": ""},
                    {"data": "payMoney", "defaultContent": ""},
                    {"data": "payAmount", "defaultContent": ""},
                    {"data": "sendMode", "defaultContent": ""},

                    /*{"data": "userId", "defaultContent": ""},
                    {"data": "receiverPhone", "defaultContent": ""},
                    {"data": "receiverAddress", "defaultContent": ""},*/


                    {"data": "status",
                        "defaultContent": "",
                        "render": function (data, type, row) {
                            console.log(data)
                            if (data == 0) {
                                data = "正常"
                            } else if (data == 1) {
                                data = "禁用"
                            }
                            return data;}
                    },
                    {"data": "orderType", "defaultContent": ""},
                    {"data": "createTime", "defaultContent": "",
                        "render":function(data) {
                            if(data==null || data==""){
                                return data;
                            }
                            var dateee = new Date(data).toJSON();
                            var date=new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
                            data=date
                            return data;
                        }},
                    {"data": "updateTime", "defaultContent": "",
                        "render":function(data) {
                            if(data==null || data==""){
                                return data;
                            }
                            var dateee = new Date(data).toJSON();
                            var date=new Date(+new Date(dateee) + 8 * 3600 * 1000).toISOString().replace(/T/g, ' ').replace(/\.[\d]{3}Z/, '')
                            data=date
                            return data;}},
                    {
                        "data": "",
                        "defaultContent": "",
                        "orderable": false,
                        "render": function (data, type, row) {
                            var id = row['goodsId'];
                            var href = "After.html?id=" + id;
                            var edit = buttonEdit(href, "shops:goods:add", pers);
                            var del = buttonDel(id, "shops:goods:delete", pers);
                            return edit + del;
                        }
                    },
                ],
                "order": [[2, "desc"]]
            });
    }

    layui.use('layer', function () {
        var layer = layui.layer;
    });

    $("#searchBt").click(function () {
        example.ajax.reload();
    });

    init();
</script>